﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace Hugo.Gesture
{
    class GestureTranslator
    {

        static MainWindow pointer;

        public GestureTranslator(MainWindow parent)
        {
            pointer = parent;
        }

        internal static void translateGesture(string s)
        {
            if (pointer == null) { return; }

            KeyEventArgs e = null;
            if (s.StartsWith("@Right hand swipe left")) {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Right);
            }
            else if (s.StartsWith("@Left hand swipe right"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Left);
            }
            else if (s.StartsWith("@Left hand swipe left"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Right);
            }
            else if (s.StartsWith("@Right hand swipe right"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Left);
            }
            else if (s.StartsWith("@Two hands zoom out"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Back);
            }   
            else if (s.StartsWith("@Two hands zoom in"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Enter);
            }
            else if (s.StartsWith("@Right hand wave") || s.StartsWith("@Left hand wave"))
            {
                e = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.H);
            }

            if (e != null)
            {
                Console.WriteLine("Match! sending key: " + e.Key);
                pointer.respondToKey(null, e);
            }
        }
    }
}
